var e = require("../../../../@babel/runtime/helpers/objectSpread2"),
  t = require("../../../../@babel/runtime/helpers/regeneratorRuntime"),
  r = require("../../../../@babel/runtime/helpers/asyncToGenerator"),
  n = require("../../../../utils/index"),
  o = require("../../utils/index"),
  a = n.helper.tabCommon,
  i = n.tools.common.getHeaderHeight;

function s() {
  return c.apply(this, arguments)
}

function c() {
  return (c = r(t().mark((function e() {
    var r, n, o, i;
    return t().wrap((function (e) {
      for (;;) switch (e.prev = e.next) {
        case 0:
          r = a.getStorageKey(), n = a.getFilterParamsInfo(r), o = n.sort, i = n.type, this.setData({
            pickLabel: (null == i ? void 0 : i.label) || "",
            sortPick: o || {}
          });
        case 2:
        case "end":
          return e.stop()
      }
    }), e, this)
  })))).apply(this, arguments)
}
Component({
  componentPage: {
    onPageScroll: function (e) {
      var t = e.scrollTop;
      this.scrollTop = t
    }
  },
  useStore: function (e) {
    var t;
    return {
      sortClass: e.global.sortClass,
      tabActive: (null === (t = e.storage.homeTabFilterParams) || void 0 === t ? void 0 : t.tabValue) || 0
    }
  },
  properties: {
    isCeilingTop: {
      type: Boolean,
      value: !1
    }
  },
  data: {
    navHeight: i("14rpx"),
    sortPickerTop: "calc(186rpx + ".concat(i("14rpx")),
    pickLabel: "",
    sortPick: "",
    showTypePicker: !1,
    showSortPicker: !1,
    tabList:[{
      title: "求租",
      mode: t.seeking,
      "filter-key": "seekingParams"
    }, {
      title: "出租",
      mode: t.hire,
      "filter-key": "hireParams"
    }, {
      title: "驾驶员招聘",
      mode: t.recruit,
      "filter-key": "driverRecruitParams"
    }
    ]
  },
  methods: {
    onTabChange: function (e) {
      var n = this;
      return r(t().mark((function r() {
        var o;
        return t().wrap((function (t) {
          for (;;) switch (t.prev = t.next) {
            case 0:
              if (t.t0 = e.detail, !t.t0) {
                t.next = 7;
                break
              }
              return t.next = 4, a.setFilterParamsInfo("tabValue", null === (o = e.detail) || void 0 === o ? void 0 : o.index);
            case 4:
              n.refresh(), s.call(n), n.onSwitchSortPicker(!1);
            case 7:
            case "end":
              return t.stop()
          }
        }), r)
      })))()
    },
    onOpenPicker: function (e) {
      var a = this;
      return r(t().mark((function r() {
        var i, s, c, u;
        return t().wrap((function (t) {
          for (;;) switch (t.prev = t.next) {
            case 0:
              if (i = e.target.dataset, s = i.type, c = i.tabActive, a.diamondRegionHeight) {
                t.next = 6;
                break
              }
              return t.next = 4, n.operateDom.getDom("#diamond-region");
            case 4:
              u = t.sent, a.diamondRegionHeight = u.height;
            case 6:
              (0, o.checkScrollTop)(a.scrollTop || 0, a.diamondRegionHeight, (function () {
                s && "sort" === s ? a.onSwitchSortPicker(!0) : (a.onSwitchSortPicker(!1), 2 !== c ? $.router.push("/subpackage/common/multi-role-select/index", {
                  type: "machinery"
                }) : a.onSwitchTypePicker())
              }));
            case 7:
            case "end":
              return t.stop()
          }
        }), r)
      })))()
    },
    onSwitchSortPicker: function (e) {
      "boolean" != typeof e ? this.setData({
        showSortPicker: !this.data.showSortPicker
      }) : this.setData({
        showSortPicker: e
      })
    },
    onSortFilterChange: function (n) {
      var o = this;
      return r(t().mark((function r() {
        var i, c;
        return t().wrap((function (t) {
          for (;;) switch (t.prev = t.next) {
            case 0:
              return i = a.getStorageKey(), c = a.getFilterParamsInfo(i), t.next = 3, a.setFilterParamsInfo(i, e(e({}, c), {}, {
                sort: n.detail || ""
              }));
            case 3:
              o.refresh(), s.call(o);
            case 5:
            case "end":
              return t.stop()
          }
        }), r)
      })))()
    },
    onSwitchTypePicker: function () {
      this.setData({
        showTypePicker: !this.data.showTypePicker
      })
    },
    onTypeFilterChange: function () {
      var e = this;
      return r(t().mark((function r() {
        return t().wrap((function (t) {
          for (;;) switch (t.prev = t.next) {
            case 0:
              e.refresh(), s.call(e);
            case 1:
            case "end":
              return t.stop()
          }
        }), r)
      })))()
    },
    onClearSelectLabel: function (e) {
      var n = this;
      return r(t().mark((function r() {
        var o;
        return t().wrap((function (t) {
          for (;;) switch (t.prev = t.next) {
            case 0:
              return o = e.target.dataset.type, t.next = 3, a.clearTabFilterStorage(o);
            case 3:
              n.refresh(), s.call(n);
            case 5:
            case "end":
              return t.stop()
          }
        }), r)
      })))()
    },
    close: function () {
      this.setData({
        showTypePicker: !1,
        showSortPicker: !1
      })
    },
    refresh: function () {
      this.triggerEvent("refresh")
    }
  },
  pageLifetimes: {
    show: function () {
      s.call(this)
    }
  }
});